package com.cvlep.appbase.mem;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public abstract class AbstractMemMapTable<K, V> implements MemMapTable<K, V> {
	protected Map<K, V> Table;

	public AbstractMemMapTable(int mapSize) {
		this.Table = new ConcurrentHashMap<K, V>(mapSize);

		// call the init method
		this.initTable();
	}

	public AbstractMemMapTable() {
		Table = new ConcurrentHashMap<K, V>();

		// call the init method
		this.initTable();
	}

	@Override
	public void refreshItem(K key, V value) {
		this.Table.put(key, value);
	}

	@Override
	public void clearTable() {
		this.Table.clear();
	}

	@Override
	public boolean containKey(K key) {
		return this.Table.containsKey(key);
	}

	@Override
	public void deleteItem(K key) {
		this.Table.remove(key);
	}

	@Override
	public V getValue(K key) {
		return this.Table.get(key);
	}

}
